package cn.lesaas.esb.component.tuxedo;

import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;

@UriEndpoint(scheme = "tuxedo", title = "Tuxedo", syntax = "tuxedo:host:port", label = "core,endpoint")
public class TuxedoEndpoint extends DefaultEndpoint {
	@UriParam
	private TuxedoConfiguration configuration;

	public TuxedoEndpoint(String endpointUri, TuxedoComponent component, TuxedoConfiguration configuration) {
		super(endpointUri, component);
		this.configuration = configuration;
	}

	@Override
	public Consumer createConsumer(Processor processor) throws Exception {
		throw new RuntimeCamelException("Cannot consumer to a TuxedoEndpoint: " + getEndpointUri());
	}

	@Override
	public Producer createProducer() throws Exception {
		Producer answer = new TuxedoProducer(this, configuration);
		return answer;
	}

	/*
	 * @Override public Exchange createExchange() { // TODO Auto-generated
	 * method stub return super.createExchange(); }
	 */

	@Override
	public boolean isSingleton() {
		return true;
	}

	@Override
	public TuxedoComponent getComponent() {
		return (TuxedoComponent) super.getComponent();
	}

	public TuxedoConfiguration getConfiguration() {
		return configuration;
	}
}
